//
//  YLCouponController.m
//  YLFinanceService
//
//  Created by she1323 on 2017/9/12.
//  Copyright © 2017年 she1323. All rights reserved.
//

#import "YLCouponController.h"
#import "YLCouponTableViewCell.h"
#import "YLGlobeHeader.h"
#import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>
@interface YLCouponController ()<DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>

@end

@implementation YLCouponController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([YLCouponTableViewCell class]) bundle:nil] forCellReuseIdentifier:[YLCouponTableViewCell cellID]];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    YLCouponTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[YLCouponTableViewCell cellID]];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.001;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return (YLScreenW - 20) / 713.0 * 183 + 10;
}

- (instancetype)init
{
    return [self initWithStyle:UITableViewStyleGrouped];
}

- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
    NSString * text = @"暂时还无任何活动券!";
    
    NSDictionary * attributes = @ { NSFontAttributeName:[UIFont boldSystemFontOfSize:14.0f ],
        NSForegroundColorAttributeName:YLLineColor};
    
    return [[ NSAttributedString  alloc ] initWithString:text attributes:attributes];
}


- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
    return [UIImage imageNamed:@"CouponTag"];
}

- (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView
{
    return 25.0f;
}

- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView
{
    return -90;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
